package com.ywl.designpattern.state;

// 有硬币状态
public class HasCoinState implements State {
    VendingMachine vendingMachine;

    public HasCoinState(VendingMachine vendingMachine) {
        this.vendingMachine = vendingMachine;
    }

    @Override
    public void insertCoin() {
        System.out.println("您已经插入了硬币");
    }

    @Override
    public void ejectCoin() {
        System.out.println("退回硬币");
        vendingMachine.setState(vendingMachine.getNoCoinState());
    }

    @Override
    public void selectItem() {
        System.out.println("商品已选择");
        vendingMachine.setState(vendingMachine.getSoldState());
    }

    @Override
    public void dispense() {
        System.out.println("请先选择商品");
    }
}
